package lanqiaoDemo;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @Author liangzai
 * @Description:
 */
public class Main {
    //蜗牛
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] x = new int[n+1];
        int[] a = new int[n+1];
        int[] b = new int[n+1];
        for (int i = 1; i <=n ; i++) {
            x[i] = scanner.nextInt();
        }
        for (int i = 1; i < n; i++) {
            a[i] = scanner.nextInt();
            b[i+1] = scanner.nextInt();
        }
        double[][] dp = new double[n+1][2];
        dp[1][0] = x[1];
        dp[1][1] = x[1] + (double)(a[1]/0.7);
        for (int i = 2; i <= n; i++) {
            if(a[i]>=b[i]){
                dp[i][1] = Math.min(dp[i-1][0]+x[i]-x[i-1]+(double) (a[i]/0.7),dp[i-1][1]+(double) ((a[i]-b[i])/0.7));
            }else {
                dp[i][1] = Math.min(dp[i-1][0]+x[i]-x[i-1]+(double) (a[i]/0.7),dp[i-1][1]+(double) ((b[i]-a[i])/1.3));
            }
            dp[i][0] = Math.min(dp[i-1][0]+x[i]-x[i-1],(double) (b[i]/1.3)+dp[i-1][1]);
        }

        System.out.printf("%.2f",dp[n][0]);
    }

    //矩形总面积
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long x1 = scanner.nextLong();
        long y1 = scanner.nextLong();
        long x2 = scanner.nextLong();
        long y2 = scanner.nextLong();
        long x3 = scanner.nextLong();
        long y3 = scanner.nextLong();
        long x4 = scanner.nextLong();
        long y4 = scanner.nextLong();
        long area = (y2-y1)*(x2-x1) + (y4-y3)*(x4-x3);
        long len = Math.max(0,Math.min(x2,x4) - Math.max(x1,x3));
        long hig = Math.max(0,Math.min(y2,y4)-Math.max(y1,y3));
        long sum = len*hig;
        System.out.println(area-sum);
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long x1 = scanner.nextLong();
        long y1 = scanner.nextLong();
        long x2 = scanner.nextLong();
        long y2 = scanner.nextLong();
        long x3 = scanner.nextLong();
        long y3 = scanner.nextLong();
        long x4 = scanner.nextLong();
        long y4 = scanner.nextLong();
        int sum = 0;
        Set<String> set = new HashSet<>();
        for (long i = x1+1; i <= x2; i++) {
            for (long j = y2; j > y1 ; j--) {
                String val = String.valueOf(i)+" "+String.valueOf(j);
                if(!set.contains(val)){
                    set.add(val);
                    sum++;
                }
            }
        }
        for (long i = x3+1; i <= x4; i++) {
            for (long j = y4; j > y3 ; j--) {
                String val = String.valueOf(i)+" "+String.valueOf(j);
                if(!set.contains(val)){
                    set.add(val);
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }

    //幸运数
    public static void main1(String[] args) {
        int count = 0;
        for (int i = 0; ; i++) {
            if(cheak(i,2) && cheak(i,8) && cheak(i,10) && cheak(i,16)){
                count++;
                System.out.println(i);
            }
            if(count==2023){
                System.out.println(i);
                break;
            }
        }
    }

    private static boolean cheak(int key, int val){
        int sum = 0;
        int cp = key;
        while(key>0){
            sum += key%val;
            key /= val;
        }
        if(cp % 10==0){
            return true;
        }
        return false;
    }
}
